package edu.zhku.ttms.view;

import com.formdev.flatlaf.FlatDarculaLaf;
import edu.zhku.ttms.utils.SystemConst;
import edu.zhku.ttms.view.menuBar.MyMenuBar;
import edu.zhku.ttms.view.panel.content.ViewPanel;

import javax.swing.*;
import java.awt.*;

/**
 * @author Feng
 * @since 2021/4/23 23:08
 */
public class ViewController {

    private static JFrame frame;

    private ViewController() {
    }

    public static void init(JFrame mainFrame) {
        frame = mainFrame;
    }

    public static void changeView(ViewPanel panel) {
        frame.setVisible(false);

        frame.setJMenuBar(panel.isShowMenuBar() ? new MyMenuBar() : null);

        frame.setContentPane(panel);
        frame.getContentPane().setBackground(SystemConst.BACKGROUND_COLOR);
        frame.setVisible(true);
    }

    public static JFrame getFrame() {
        return frame;
    }
}
